/*kZime*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <algorithm>

using namespace std;
/*-----------------------------------------------------------------------------*/
inline void File_Read() {
#ifndef DEBUG
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#else
	freopen("in.txt", "r", stdin);
#endif
}

inline int get_num() {
	int k = 0, f = 1; char c = getchar();
	for(; !isdigit(c); c = getchar())if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
	return k * f;
}

int t, n;
char ans[55];
char id[20];
int xx[5] = {0, 1000, 100, 10, 1};

bool check(char a[]) {
	int k = 0;
	int tmp = 1;
	for(int i = 15; i >= 0; i--) {
		k += (a[i] - '0') * tmp;
		tmp *= 2;
	}
	tmp = get_num();
	
	
	if(k > 10000 || k < 1)return 0;
	else {
		printf("ID: %d\n", k);
		if(((tmp == 1) && id[15] == '1' || (tmp == 10) && id[15] == '0'))printf("Type Correct\n");
		else printf("Type Incorrect\n");
	}
	return 1;
}

int main() {
//	File_Read();
	t = get_num();
	n = get_num();
	cin >> ans;
	while (t--) {
		cin >> id;
		if(!check(id)) {
			printf("Wrong ID\n\n");
			for(int i = 0; i < n; i++) {
				get_num();
			}
			continue;
		}
		double ef = 100.0 / n;
		double gra = 0.0;
		
		for(int i = 0; i < n; i++) {
			int tmp = get_num();
			if(tmp == xx[ans[i] - 'A' + 1]) gra += ef;
		}
		printf("%.1lf\n\n", gra);
	}
	return 0;
}

